package com.masterclient.app.businessmodule.vipmodule.persenter;

import com.eoner.baselib.container.CommonBaseResponse;
import com.eoner.baselib.presenter.FCBaseCallBack;
import com.eoner.baselib.presenter.FCBasePresenter;
import com.masterclient.app.businessmodule.vipmodule.api.SaleOrderListService;
import com.masterclient.app.businessmodule.vipmodule.bean.OrderBean;
import com.masterclient.app.businessmodule.vipmodule.bean.ServiceOrderBean;


public class SaleOrderListPresenter extends SaleOrderListContract.Presenter {


    @Override
    public void getOrderList(boolean showPageLoading, String status, int page, int size) {
        if (showPageLoading)
            mView.baseShowPageLoading(false);
        mRxManager.add(toNewSubscribe(SaleOrderListService.getInstance().getOrderList(status, page, size),
                new FCBaseCallBack<CommonBaseResponse<OrderBean>>() {
                    @Override
                    public void onSuccess(CommonBaseResponse<OrderBean> bean) {
                        mView.getOrderList(bean.getData());
                    }

                    @Override
                    public void onNetWorkError(String errorMsg) {
                        super.onNetWorkError(errorMsg);
                        mView.error(FCBasePresenter.WEB_FAILED_STR);
                    }

                    @Override
                    public void onServiceError(CommonBaseResponse<OrderBean> obj) {
                        super.onServiceError(obj);
                        mView.error(FCBasePresenter.SERVER_FAILED_STR);
                    }
                }));
    }

    @Override
    public void getNotOrderList(boolean showPageLoading, int page, int size) {
        if (showPageLoading)
            mView.baseShowPageLoading(false);
        mRxManager.add(toNewSubscribe(SaleOrderListService.getInstance().getNotOrderList(page, size),
                new FCBaseCallBack<CommonBaseResponse<OrderBean>>() {
                    @Override
                    public void onSuccess(CommonBaseResponse<OrderBean> bean) {
                        mView.getOrderList(bean.getData());
                    }

                    @Override
                    public void onNetWorkError(String errorMsg) {
                        super.onNetWorkError(errorMsg);
                        mView.error(FCBasePresenter.WEB_FAILED_STR);
                    }

                    @Override
                    public void onServiceError(CommonBaseResponse<OrderBean> obj) {
                        super.onServiceError(obj);
                        mView.error(FCBasePresenter.SERVER_FAILED_STR);
                    }
                }));
    }

    @Override
    public void getRefundList(boolean showPageLoading, String status, int page, int size) {
        if (showPageLoading)
            mView.baseShowPageLoading(false);
        mRxManager.add(toNewSubscribe(SaleOrderListService.getInstance().getRefundList(status, page, size),
                new FCBaseCallBack<CommonBaseResponse<ServiceOrderBean>>() {
                    @Override
                    public void onSuccess(CommonBaseResponse<ServiceOrderBean> bean) {
                        mView.getServiceOrderList(bean.getData());
                    }

                    @Override
                    public void onNetWorkError(String errorMsg) {
                        super.onNetWorkError(errorMsg);
                        mView.error(FCBasePresenter.WEB_FAILED_STR);
                    }

                    @Override
                    public void onServiceError(CommonBaseResponse<ServiceOrderBean> obj) {
                        super.onServiceError(obj);
                        mView.error(FCBasePresenter.SERVER_FAILED_STR);
                    }
                }));
    }


}
